package com.hyt.it.ogt.ks.enums;

import lombok.Getter;

import java.util.Objects;


/**
 *
 * 设备检测状态 '0 未检测、1 已通过、2 已跳过、3 未通过 4 未获权
 */
@Getter
public enum DeviceCheckState {
    STATE_ZERO(0,"未检测"),
    STATE_ONE(1,"已通过"),
    STATE_TWO(2,"已跳过"),
    STATE_THREE(3,"未通过"),
    STATE_FOUR(4,"未获权");

    private Integer code;
    private String msg;

    DeviceCheckState(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    /**
     * 方法用与考生轨迹显示，做了处理，调用前判断是否符合你的业务逻辑
     * @param code
     * @return
     */
    public static String getByCode(Integer code){
        if(Objects.isNull(code)){
            return DeviceCheckState.STATE_ZERO.getMsg();
        }
        for(DeviceCheckState state : DeviceCheckState.values()){
            if(Objects.equals(code,state.getCode())){
                return state.getMsg();
            }
        }
        return DeviceCheckState.STATE_ZERO.getMsg();
    }
}
